﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;

namespace WcfService
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "MyCourseService" in code, svc and config file together.
   
    public class MyCourseService : IMyCourseService
    {
        
        public DataSet CourseList(string ID)
        {
            DataSet myDS = new DataSet();
              using (SqlConnection myConn = new SqlConnection(ConfigurationManager.ConnectionStrings["prodTmsEPrd"].ConnectionString))
             {

                try
                {
                    myConn.Open();
                    myConn.Open();

                    SqlDataAdapter myDataAdapter = new SqlDataAdapter("CUS_sp_CourseDetails", myConn);
                    myDataAdapter.SelectCommand.CommandType = CommandType.StoredProcedure;
                    //Create and add a parameter to Parameters collection for the stored procedure.
                    myDataAdapter.SelectCommand.Parameters.Add(new SqlParameter("@id", SqlDbType.VarChar, 10));
                    //Assign the search value to the parameter.
                    myDataAdapter.SelectCommand.Parameters["@id"].Value = ID;

                    myDataAdapter.Fill(myDS, "view2");
                    // DataTable dt = new DataTable();
                    // myDataAdapter.Fill(dt);

                }
                catch (Exception err)
                {
                    string errMsg = err.Message;

                }
                finally
                {
                    myConn.Close();
                }

                }


            return myDS;
        }

        public void DoWork()
        {
        }
    }
}
